package com.biyao.service.model.base.imp;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import java.util.HashMap;
import java.util.Map;

import com.biyao.schedulingdao.base.TRollerRacksMapper;
import com.biyao.schedulingentity.base.TRollerRacksEntity;
import com.biyao.service.model.base.TRollerRacksMessage;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.ArrayList;
/**
 * 
 *
 * @author code generator
 * @date 2019-09-16 09:44:09
 */
@Service
public class TRollerRacksService extends ServiceImpl<TRollerRacksMapper, TRollerRacksEntity> implements TRollerRacksMessage {

    public Page list(int pageNum, int pageSize){

        EntityWrapper<TRollerRacksEntity> tRollerRacksentityWrapper=new EntityWrapper<>();
        Page page=selectPage(new Page(pageNum,pageSize),tRollerRacksentityWrapper);
        page.setRecords(formatRecords(page.getRecords()));
        return page;
    }

    List formatRecords(List<TRollerRacksEntity> list){
        List resList=new ArrayList();
        for(TRollerRacksEntity tRollerRacksEntity:list){
            Map map=formatEntity(tRollerRacksEntity);
            resList.add(map);
        }
        return resList;
    }

    Map formatEntity(TRollerRacksEntity tRollerRacksEntity){
        Map map=new HashMap(16);
        //辊架信息
        if(tRollerRacksEntity.getId()!=null){
           map.put("id",tRollerRacksEntity.getId());
        }
        //辊架编号
        if(tRollerRacksEntity.getCode()!=null){
           map.put("code",tRollerRacksEntity.getCode());
        }
        //辊架类型
        if(tRollerRacksEntity.getType()!=null){
           map.put("type",tRollerRacksEntity.getType());
        }
        //辊架状态
        if(tRollerRacksEntity.getState()!=null){
           map.put("state",tRollerRacksEntity.getState());
        }
        //辊架位置X
        if(tRollerRacksEntity.getLocationX()!=null){
           map.put("locationX",tRollerRacksEntity.getLocationX());
        }
        //辊架位置Y
        if(tRollerRacksEntity.getLocationY()!=null){
           map.put("locationY",tRollerRacksEntity.getLocationY());
        }
        //辊架位置Z
        if(tRollerRacksEntity.getLocationZ()!=null){
           map.put("locationZ",tRollerRacksEntity.getLocationZ());
        }
        //生产厂家
        if(tRollerRacksEntity.getManufacturer()!=null){
           map.put("manufacturer",tRollerRacksEntity.getManufacturer());
        }
        //生产日期
        if(tRollerRacksEntity.getManufactureDate()!=null){
           map.put("manufactureDate",tRollerRacksEntity.getManufactureDate());
        }
        //
        if(tRollerRacksEntity.getRemark()!=null){
           map.put("remark",tRollerRacksEntity.getRemark());
        }
        if(tRollerRacksEntity.getSemaphore()!=null){
            map.put("semaphore",tRollerRacksEntity.getSemaphore());

        }
        //
        if(tRollerRacksEntity.getCreateTime()!=null){
           map.put("createTime",tRollerRacksEntity.getCreateTime());
        }
        //
        if(tRollerRacksEntity.getUpdateTime()!=null){
           map.put("updateTime",tRollerRacksEntity.getUpdateTime());
        }
        //
        if(tRollerRacksEntity.getCreateBy()!=null){
           map.put("createBy",tRollerRacksEntity.getCreateBy());
        }
        //
        if(tRollerRacksEntity.getUpdateBy()!=null){
           map.put("updateBy",tRollerRacksEntity.getUpdateBy());
        }
        if(tRollerRacksEntity.getRollerCode()!=null){
            map.put("rollerCode",tRollerRacksEntity.getRollerCode());
        }
        if(tRollerRacksEntity.getNowCode()!=null){
            map.put("nowCode",tRollerRacksEntity.getNowCode());
        }
        return map;
    }

    @Override
    public TRollerRacksEntity selectTRollerEntityById(Integer id) {
        if(id!=null){
            return selectById(id);
        }
        return null;
    }
}

